<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>制作库存单</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script src="../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>

  <script src="../../layui-v2.5.5/layui/layui.all.js"></script>
  <script src="../../layui-v2.5.5/layui/css/layui.css"></script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
            <td valign="bottom" class="title">制作库存单</td>
          </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="/drug/drugStorageController/addWaeInfo" class="_form01">
    <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="90" height="24" class="td_form01">制作人</td>
      <td class="td_form02">
        <input type="text" class="staname" size="10" >
      </td>
      <td width="90" class="td_form01" >性别</td>
      <td class="td_form02">
        <select class="stasex">
          <option>男</option>
          <option>女</option>
        </select>
      </td>
    </tr>
    <tr>

      <td class="td_form01">工号</td>
      <td class="td_form02">
        <input type="input" class="staid" size="10" name="waentry.staid">
      </td>
    </tr>

  </table>
    <hr>
    <table width="1000" size="1" class="table02">
      <tr>

        <td class="td_form01">药品名称</td>
        <td class="td_form01">药品数量</td>
        <td class="td_form01">单价</td>
        <td class="td_form01">药品类别</td>
        <td class="td_form01">生产日期</td>
        <td class="td_form01">有效期(月)</td>
        <td class="td_form01">库存单位</td>
        <td class="td_form01">药房</td>
        <td class="td_form01" width="70">报警日期</td>

        <td class="td_form01">报警值</td>
<!--        <td class="td_form01">选择</td>-->
        <td class="td_form01">操作</td>
      </tr>
      <tr>
        <td class="td_form02">
          <input type="text" size="5" class="drugname" name="druginformation[0].drugname">
        </td>
        <td class="td_form02">
          <input type="text" size="5" class="drugnumber" name="druginformation[0].drugnumber">
        </td>
        <td class="td_form02">
          <input type="text" size="3" class="drugprice" name="druginformation[0].drugprice">
        </td>
        <td class="td_form02">
          <select class="druname" name="druginformation[0].druid">
            <option value="1">片剂</option>
            <option value="2">胶囊剂</option>
            <option value="3">注射剂</option>

          </select>
        </td>

        <td class="td_form02">
          <input type="date" class="drugdate" name="druginformation[0].drugdate">
        </td>
        <td class="td_form02">
          <input type="text" class="dugperiod" name="druginformation[0].dugperiod">
        </td>
        <td class="td_form02">
          <select class="pridunit" name="druginformation[0].prid">
            <option value="1">箱</option>
            <option value="2">盒</option>
            <option value="3">瓶</option>

          </select>
        </td>
        <td class="td_form02">
          <select class="phaname" name="druginformation[0].phaid">
            <option value="1">药房A</option>
            <option value="2">药房B</option>
            <option value="3">药房C</option>
          </select>
        </td>
        <td class="td_form02">
          <input type="date" class="drugplidate" name="druginformation[0].drugplidate">
        </td>

        <td class="td_form02">
          <input class="drugplival" type="text" name="druginformation[0].drugplival">
        </td>

        <td class="td_form02">
          <input type="button" class="add" value="添加" onclick='add()'>
          <input type="button" class="del" value="删除" onclick="del(this)">
        </td>
      </tr>
    </table>
    <br>
    <table width=95% border=0 align=center cellpadding=0 cellspacing=0 whdth='100%'>
      <tr>
        <td align="center">

            <input name=save  type='button' class="sub" value= '  提交  '  >
            <input name=cancel  type=button class="return" value= '  返回  ' ></td>
      </tr>
    </table>
  </form>
</center>
</body>
</html>
<script src="../../js/jquery.js">
</script>


<script>
  function _return(){

  }

  $(".sub").click(function () {
    // alert($("._form01").serializeArray());
      $.ajax({
        url:"/feign/drugStorageController/addWaeInfo",
        type:"post",
        headers: {
          Accept: "application/json; charset=utf-8",
          Authorization: location.href.split("=")[1]
        },
        data:$("._form01").serializeArray(),
        dataType: "text",
        success:function(data){
          if(data=="success"){
            layer.msg("制作成功")
          }else{
            layer.msg("添加失败，重新输入")
          }
        }
      })

  })
</script>
<script>
  var i=$(".add").length;

  var _tr =" <tr>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input type=\"text\" size=\"5\" class=\"drugname\" name="+'druginformation['+i+'].drugname'+">\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input type=\"text\" size=\"5\" class=\"drugnumber\" name="+'druginformation['+i+'].drugnumber'+">\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input type=\"text\" size=\"3\" class=\"drugprice\" name="+'druginformation['+i+'].drugprice'+">\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <select class=\"druname\" name="+'druginformation['+i+'].druid'+">\n" +
          "            <option value=\"1\">片剂</option>\n" +
          "            <option value=\"2\">胶囊剂</option>\n" +
          "            <option value=\"3\">注射剂</option>\n" +
          "\n" +
          "          </select>\n" +
          "        </td>\n" +
          "\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input type=\"date\" class=\"drugdate\" name="+'druginformation['+i+'].drugdate'+">\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input type=\"text\" class=\"dugperiod\" name="+'druginformation['+i+'].dugperiod'+">\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <select class=\"pridunit\" name="+'druginformation['+i+'].prid'+">\n" +
          "            <option value=\"1\">箱</option>\n" +
          "            <option value=\"2\">盒</option>\n" +
          "            <option value=\"3\">瓶</option>\n" +
          "\n" +
          "          </select>\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <select class=\"phaname\" name="+'druginformation['+i+'].phaid'+">\n" +
          "            <option value=\"1\">药房A</option>\n" +
          "            <option value=\"2\">药房B</option>\n" +
          "            <option value=\"3\">药房C</option>\n" +
          "          </select>\n" +
          "        </td>\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input type=\"date\" class=\"drugplidate\" name="+'druginformation['+i+'].drugplidate'+">\n" +
          "        </td>\n" +
          "\n" +
          "        <td class=\"td_form02\">\n" +
          "          <input class=\"drugplival\" type=\"text\" name="+'druginformation['+i+'].drugplival'+">\n" +
          "        </td>\n" +

          "        <td class=\"td_form02\">\n" +
          "          <input type=\"button\" class=\"add\" value=\"添加\" onclick='add()'>\n" +
          "          <input type=\"button\" class=\"del\" value=\"删除\" onclick=\"del(this)\">\n" +
          "        </td>\n" +
          "      </tr>"

  //添加一行
  function add() {
    // alert("添加")
    console.log(i)
    $(".table02").append(_tr);

    i=$(".add").length;

  }
  //删除一行
  function del($this) {
    // alert("删除")
    $($this).parent().parent().remove();
  }
</script>

